#include "slepdef.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void initOPTS(OPTS* opt,int m,int n,int k){
	int i=0;

	opt->m = m;
	opt->n = n;

	opt->registry[0] = '\0';
	opt->init = 2;
	opt->x0 = NULL;
	opt->c0 = 0.0;

	//Termination
	opt->maxIter = 10000;
	opt->tol = 0.0001;
	opt->tFlag = 5; // Max iterations is default

	//Normalization
	opt->nFlag = 0;
	opt->mu = NULL;
	opt->nu = NULL;

	// Method
	opt->method = 0;
	opt->lFlag = 0;

	// Regularization
	opt->rFlag = 0;
	opt->rsL2 = 0.0;

}

void setOPTx0(OPTS* opt,double* x0){
	if(strstr(opt->registry,"x0")== NULL && x0!= NULL)
		strcat(opt->registry,"x0");
	opt->x0 = x0;
}

void setOPTc0(OPTS* opt,double c0){
	if(strstr(opt->registry,"c0")== NULL )
		strcat(opt->registry,"c0");
	opt->c0 = c0;
}
void setOPTmt_c0(OPTS *opt,double* mt_c0){
	if(strstr(opt->registry,"mt_c0")== NULL && mt_c0!= NULL)
		strcat(opt->registry,"mt_c0");
	opt->mt_c0 = mt_c0;
}

void setOPTmc_c0(OPTS *opt,double* mc_c0){
	if(strstr(opt->registry,"mc_c0")== NULL && mc_c0!= NULL)
		strcat(opt->registry,"mc_c0");
	opt->mc_c0 = mc_c0;
}


void setOPTmu(OPTS* opt,double* mu){
	if(strstr(opt->registry,"mu")== NULL && mu!= NULL)
		strcat(opt->registry,"mu");
	opt->mu = mu;
}

void setOPTnu(OPTS* opt,double* nu){
	if(strstr(opt->registry,"nu")== NULL && nu!= NULL)
		strcat(opt->registry,"nu");
	opt->nu = nu;
}

void setOPTsWeight(OPTS* opt,double* sWeight){
	if(strstr(opt->registry,"sWeight")== NULL && sWeight!= NULL)
		strcat(opt->registry,"sWeight");
	opt->sWeight[0] = sWeight[0];
	opt->sWeight[1] = sWeight[1];
}



void setOPTind(OPTS* opt,int* ind, int ind_size){
	if(strstr(opt->registry,"ind")== NULL && ind!= NULL)
		strcat(opt->registry,"ind");
	opt->ind = ind;
	opt->ind_size = ind_size;
}

void setOPTq(OPTS* opt,double q){
	if(strstr(opt->registry,"q")== NULL && q>1.0)
		strcat(opt->registry,"q");
	opt->q = q;
}

void setOPTgWeights(OPTS* opt,double *gWeights){
	if(strstr(opt->registry,"gWeights")== NULL && gWeights!= NULL)
		strcat(opt->registry,"gWeights");
	opt->gWeights = gWeights;
}

int hasGot(OPTS *opt,char * field){
	if(strstr(opt->registry,field)== NULL)
		return 0;
	return 1;
}
